Sensitive information and related configuration, such as CKAN URLs and credentials, are stored in a separate file.
To use this workbook on your own CKAN instance, write or append the following contents into a file secret.py
in the same directory as this workbook:
ARCGIS = {
"SLIPFUTURE" : {
"url": "http://services.slip.wa.gov.au/arcgis/rest/services",
"folders": ["QC", ...]
},
...
}
Insert your ArcGIS REST endpoints and service names.
In [1]:
import ckanapi
from datetime import datetime
import json
import os
import requests
from slugify import slugify
from harvest_helpers import *
from secret import CKAN, ARCGIS
print("The ARCGIS REST service endpoint QC lives at {0}".format(ARCGIS["SLIPFUTURE"]["url"]))
print("The catalogue \"ca\" lives at {0}".format(CKAN["ca"]["url"]))
print("The catalogue \"cb\" lives at {0}".format(CKAN["cb"]["url"]))
print("The catalogue \"ct\" lives at {0}".format(CKAN["ct"]["url"]))
## enable one of:
#ckan = ckanapi.RemoteCKAN(CKAN["ct"]["url"], apikey=CKAN["ct"]["key"])
ckan = ckanapi.RemoteCKAN(CKAN["ca"]["url"], apikey=CKAN["ca"]["key"])
#ckan = ckanapi.RemoteCKAN(CKAN["cb"]["url"], apikey=CKAN["cb"]["key"])
print("Using CKAN {0}".format(ckan.address))
In [2]:
baseurl = ARCGIS["SLIPFUTURE"]["url"]
folders = ARCGIS["SLIPFUTURE"]["folders"]
print("The base URL {0} contains folders {1}\n".format(baseurl, str(folders)))
services = get_arc_services(baseurl, folders[0])
print("The services in folder {0} are:\n{1}\n".format(str(folders), str(services)))
service_url = services[0]
mrwa = get_arc_servicedict(services[0])
print("Service {0}\ncontains layers and extensions:\n{1}".format(services[0], mrwa))
In [3]:
harvest_arcgis_service(services[0],
ckan,
owner_org_id = ckan.action.organization_show(id="mrwa")["id"],
author = "Main Roads Western Australia",
author_email = "irissupport@mainroads.wa.gov.au",
debug=False)
In [5]:
a = ["SLIP Classic", "Harvested"]
a.append("test")
a
Out[5]:
In [ ]: